﻿using BrightIdeasSoftware;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp1
{
    public class UcFastObjectListView:FastObjectListView
    {
        public class LsvFileInfo
        {
            public string FileName { get; set; }
            public string NewFileName { get; set; }
            public string Path { get; set; }
            public string CrTime { get; set; }
            public string MTime { get; set; }
            public string Size { get; set; }
            public string Status { get; set; }
            public string Oper { get; set; }
        }

        public UcFastObjectListView() 
        {
            InitFastObjectListView();
        }

        public void SetDataSource(string[] fileNams, string rule = "")
        {
            List<LsvFileInfo> lsvInfo = new List<LsvFileInfo>();
            foreach (string item in fileNams)
            {
                //LsvFileInfo file_info = new LsvFileInfo();
                //file_info.FileName = Path.GetFileName(item);
                //file_info.NewFileName = Path.GetFileName(item);
                //file_info.Path = Path.GetDirectoryName(item);
                //file_info.Status = "待操作";
                //file_info.Size = 10;
                //file_info.CrTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                //file_info.MTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                //file_info.Oper = "打开  删除";
                //lsvInfo.Add(file_info);
            }
            SetObjects(lsvInfo);
        }
        #region 私有函数
        private void InitFastObjectListView()
        {
            //RowHeight = 35; //行高
            //UseCompatibleStateImageBehavior = false;
            //UseFiltering = true;//过滤器
            //FullRowSelect = true;//整行选择
            //MultiSelect = true;  //选择多行
            //CellEditActivation = ObjectListView.CellEditActivateMode.SingleClick;//编辑模式
            //EmptyListMsg = "信息为空值";
            //AlternateRowBackColor = Color.FromArgb(192, 255, 192);//颜色交替出现
            //UseAlternatingBackColors = true;
            InitColumns();
        }

        public void InitColumns()
        {
            OLVColumn 原文件名 = new OLVColumn("原文件名", "FileName");
            原文件名.IsEditable = false;
            原文件名.Width = 150;
            Columns.Add(原文件名);

            OLVColumn 新文件名 = new OLVColumn("新文件名", "NewFileName");
            新文件名.Width = 150;
            Columns.Add(新文件名);

            OLVColumn 文件路径 = new OLVColumn("文件路径", "Path");
            文件路径.IsEditable = false;
            文件路径.Width = 300;
            Columns.Add(文件路径);

            OLVColumn 创建时间 = new OLVColumn("创建时间", "CrTime");
            创建时间.IsEditable = false;
            创建时间.Width = 170;
            //创建时间.AspectToStringFormat = "";
            Columns.Add(创建时间);

            OLVColumn 修改时间 = new OLVColumn("修改时间", "MTime");
            修改时间.IsEditable = false;
            修改时间.Width = 170;
            Columns.Add(修改时间);

            OLVColumn 大小 = new OLVColumn("大小", "Size");
            大小.IsEditable = false;
            大小.Width = 60;
            Columns.Add(大小);

            OLVColumn 状态 = new OLVColumn("状态", "Status");
            状态.IsEditable = false;
            Columns.Add(状态);

            OLVColumn 操作 = new OLVColumn("操作", "Oper");
            操作.IsEditable = false;
            Columns.Add(操作);
        }
        #endregion
    }
}
